package com.cf.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cf.domain.ResponseResult;
import com.cf.domain.pojo.Ground;
import com.cf.domain.pojo.Judges;
import com.cf.domain.pojo.PageQuery;
import com.cf.domain.pojo.ScoreOptions;
import com.cf.service.IGroundService;
import com.cf.service.IJudgesService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author lzqinga@126.com
 * @Date 2024/11/11  11:03
 */
@Controller
@RequestMapping("/ground")
@RequiredArgsConstructor
public class GroundController {

    private final IGroundService groundService;
    /**
     * 添加
     */
    @PostMapping
    @ResponseBody
    public ResponseResult save(@RequestBody Ground ground){
        groundService.save(ground);
        return ResponseResult.sucess();
    }

    @PutMapping
    @ResponseBody
    public ResponseResult update(@RequestBody Ground ground){
        groundService.updateById(ground);
        return ResponseResult.sucess();
    }

    @GetMapping("/{id}")
    @ResponseBody
    public ResponseResult getById(@PathVariable Long id){
        Ground ground = groundService.getById(id);
        return ResponseResult.sucess(ground);
    }

    @GetMapping("/list")
    @ResponseBody
    public ResponseResult list(){
        List<Ground> data = groundService.list();
        return ResponseResult.sucess(data);
    }

}
